<template>
  <zh-form-card title="基本信息" :span="24">
    <zh-form ref="formRef" :model="data.formData" label-width="200px" :span="12" :rules="data.rules">
            <zh-form-input
          prop="hhid"
          label="户号内部id"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hhid"
      ></zh-form-input>
      <zh-form-input
          prop="hh"
          label="户号"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hh"
      ></zh-form-input>
      <zh-form-input
          prop="contractor"
          label="承办人"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.contractor"
      ></zh-form-input>
      <zh-form-input
          prop="ryzt"
          label="人员状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.ryzt"
      ></zh-form-input>
      <zh-form-input
          prop="ryid"
          label="人员id"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.ryid"
      ></zh-form-input>
      <zh-form-input
          prop="idcard"
          label="公民身份证件编码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.idcard"
      ></zh-form-input>
      <zh-form-input
          prop="fullName"
          label="姓名"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.fullName"
      ></zh-form-input>
      <zh-form-input
          prop="beforeName"
          label="曾用名"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.beforeName"
      ></zh-form-input>
      <zh-form-input
          prop="height"
          label="身高"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.height"
      ></zh-form-input>
      <zh-form-input
          prop="birthday"
          label="出生日期"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.birthday"
      ></zh-form-input>
      <zh-form-input
          prop="birthplace"
          label="出生地"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.birthplace"
      ></zh-form-input>
      <zh-form-input
          prop="sex"
          label="性别"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.sex"
      ></zh-form-input>
      <zh-form-input
          prop="country"
          label="国家"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.country"
      ></zh-form-input>
      <zh-form-input
          prop="nation"
          label="民族"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.nation"
      ></zh-form-input>
      <zh-form-input
          prop="nativePlace"
          label="籍贯"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.nativePlace"
      ></zh-form-input>
      <zh-form-input
          prop="addressCity"
          label="户口所在地县市"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.addressCity"
      ></zh-form-input>
      <zh-form-input
          prop="addressCountry"
          label="户口所在乡镇街道"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.addressCountry"
      ></zh-form-input>
      <zh-form-input
          prop="addressVillage"
          label="户口所在村社区"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.addressVillage"
      ></zh-form-input>
      <zh-form-input
          prop="addressVillageDetail"
          label="户口所在地街路巷"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.addressVillageDetail"
      ></zh-form-input>
      <zh-form-input
          prop="mlxz"
          label="户口所在地门楼详址:mlxz和mlph只有其中一个"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.mlxz"
      ></zh-form-input>
      <zh-form-input
          prop="mlph"
          label="户口所在地门楼牌号:mlxz和mlph只有其中一个"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.mlph"
      ></zh-form-input>
      <zh-form-input
          prop="address"
          label="户口所在完整地址"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.address"
      ></zh-form-input>
      <zh-form-input
          prop="addressId"
          label="关联地址id"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.addressId"
      ></zh-form-input>
      <zh-form-input
          prop="householdPlace"
          label="户籍所在地"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.householdPlace"
      ></zh-form-input>
      <zh-form-input
          prop="street"
          label="所属街道"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.street"
      ></zh-form-input>
      <zh-form-input
          prop="maritalStatus"
          label="婚姻状况"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.maritalStatus"
      ></zh-form-input>
      <zh-form-input
          prop="culturalLevel"
          label="文化程度"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.culturalLevel"
      ></zh-form-input>
      <zh-form-input
          prop="religion"
          label="宗教信仰"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.religion"
      ></zh-form-input>
      <zh-form-input
          prop="bloodType"
          label="血型"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.bloodType"
      ></zh-form-input>
      <zh-form-input
          prop="veteranTatus"
          label="兵役状况"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.veteranTatus"
      ></zh-form-input>
      <zh-form-input
          prop="householderIdcard"
          label="户主身份证"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.householderIdcard"
      ></zh-form-input>
      <zh-form-input
          prop="householder"
          label="户主姓名"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.householder"
      ></zh-form-input>
      <zh-form-input
          prop="accountType"
          label="户口类型"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.accountType"
      ></zh-form-input>
      <zh-form-input
          prop="relation"
          label="与户主关系"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.relation"
      ></zh-form-input>
      <zh-form-input
          prop="pcs"
          label="户口登记公安机关编码"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.pcs"
      ></zh-form-input>
      <zh-form-date
          prop="registrationDate"
          label="登记日期"
          type="datetime"
          :disabled="props.disabled"
          v-model="data.formData.registrationDate"
          :span="8"
      ></zh-form-date>
      <zh-form-input
          prop="registrationAuthority"
          label="登记机关"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.registrationAuthority"
      ></zh-form-input>
      <zh-form-input
          prop="qfjg"
          label="签发机关"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.qfjg"
      ></zh-form-input>
      <zh-form-input
          prop="hssqlbz"
          label="何省市迁来本址"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hssqlbz"
      ></zh-form-input>
      <zh-form-input
          prop="hssqxqlws"
          label="何县区来本市"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hssqxqlws"
      ></zh-form-input>
      <zh-form-input
          prop="hxzlbd"
          label="何详址来本址"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hxzlbd"
      ></zh-form-input>
      <zh-form-input
          prop="hsqlbs"
          label="何时迁来本市"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hsqlbs"
      ></zh-form-input>
      <zh-form-input
          prop="hsqlbz"
          label="何时迁来本址"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.hsqlbz"
      ></zh-form-input>
      <zh-form-input
          prop="cityOtherAddress"
          label="本市(县)其他地址"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.cityOtherAddress"
      ></zh-form-input>
      <zh-form-input
          prop="serviceSpaces"
          label="服务处所"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.serviceSpaces"
      ></zh-form-input>
      <zh-form-input
          prop="number"
          label="编号"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.number"
      ></zh-form-input>
      <zh-form-date
          prop="tongTime"
          label="数据归集日期"
          type="datetime"
          :disabled="props.disabled"
          v-model="data.formData.tongTime"
          :span="8"
      ></zh-form-date>
      <zh-form-input
          prop="primarySchoolOne"
          label="可就读小学顺位1"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.primarySchoolOne"
      ></zh-form-input>
      <zh-form-input
          prop="primarySchoolTwo"
          label="可就读小学顺位2"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.primarySchoolTwo"
      ></zh-form-input>
      <zh-form-input
          prop="primarySchoolThree"
          label="可就读小学顺位3"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.primarySchoolThree"
      ></zh-form-input>
      <zh-form-input
          prop="primarySchoolFour"
          label="可就读小学顺位4"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.primarySchoolFour"
      ></zh-form-input>
      <zh-form-input
          prop="juniorSchoolOne"
          label="可就读初中顺位1"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.juniorSchoolOne"
      ></zh-form-input>
      <zh-form-input
          prop="juniorSchoolTwo"
          label="可就读初中顺位2"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.juniorSchoolTwo"
      ></zh-form-input>
      <zh-form-input
          prop="juniorSchoolThree"
          label="可就读初中顺位3"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.juniorSchoolThree"
      ></zh-form-input>
      <zh-form-input
          prop="juniorSchoolFour"
          label="可就读初中顺位4"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.juniorSchoolFour"
      ></zh-form-input>
      <zh-form-input
          prop="qysj"
          label="启用时间"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.qysj"
      ></zh-form-input>
      <zh-form-input
          prop="xxqysj"
          label="迁移时间"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.xxqysj"
      ></zh-form-input>
      <zh-form-input
          prop="yxqxqsrq"
          label="有效期起始日期"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.yxqxqsrq"
      ></zh-form-input>
      <zh-form-input
          prop="yxqxjzrq"
          label="有效期截止日期"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.yxqxjzrq"
      ></zh-form-input>
      <zh-form-input
          prop="jlbz"
          label="记录标志"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.jlbz"
      ></zh-form-input>
      <zh-form-input
          prop="year"
          label="年份"
          type="number"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.year"
      ></zh-form-input>
      <zh-form-input
          prop="authStatus"
          label="审核状态"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.authStatus"
      ></zh-form-input>
      <zh-form-input
          prop="status"
          label="是否启用0.禁用1.启用"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.status"
      ></zh-form-input>
      <zh-form-input
          prop="areaCode"
          label="行政区划"
          :disabled="props.disabled"
          :span="8"
          v-model="data.formData.areaCode"
      ></zh-form-input>
    </zh-form>
  </zh-form-card>
</template>

<script lang="ts" setup name="eduHouseHoldOfflineForm">
import { ElMessage } from 'element-plus';

//------------------定义子组件---------------------------
const formRef = ref();
//------------------接收传入参数(组件)-------------------
const props = defineProps({
  householdId: {
    type: String,
    default: '',
  },
  disabled: {
    type: Boolean,
    default: true,
  },
  btnLoding: Boolean,
});
const emits = defineEmits(['update:btnLoding', 'canner', 'refreshTable']);
//------------------初始化------------------------------
onMounted(() => {
  getDict();
  getsurveyInfo();
});
//------------------内部变量定义-------------------------
const data = reactive({
  formData: {} as any,
  detailVisible: true,
  loading: false,
  rules: {
  },
  dictData: {} as any,
  areaCodeDict: [] as any,
  campusParam: {} as any,
});

// 查询数据字典信息
const getDict = () => {
  const params = {} as any;
  params.dictFields = '';
  $api.common.getBatchDict.post(params).then((res) => {
    data.dictData = res.result;
  });
};

//获取详情
const getsurveyInfo = () => {
  if (!props.householdId) {
    return;
  }
  data.loading = true;
  $api.common.send
  .post('eduHouseHoldOffline0002', { householdId: props.householdId })
  .then((res: any) => {
    data.formData = res.result || {};
    data.loading = false;
    data.campusParam.schoolId = data.formData.schoolId;
  })
  .catch(() => {
    data.loading = false;
  });
};

//保存
async function saveBase() {
  let checkFlag = await formRef.value.checkForm();
  if (checkFlag) {
    if (data.formData.householdId) {
      $api.common.send
      .post('eduHouseHoldOffline0005', data.formData)
      .then(() => {
        ElMessage.success('修改成功');
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = false));
        emits('refreshTable');
      })
      .catch(() => {
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = true));
      });
    } else {
      $api.common.send
      .post('eduHouseHoldOffline0004', data.formData)
      .then(() => {
        ElMessage.success('新增成功');
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = false));
        emits('refreshTable');
      })
      .catch(() => {
        emits('update:btnLoding', false);
        emits('canner', (data.detailVisible = true));
      });
    }
  }
}

//------------设置给父组件调用的数据/方法(组件)-----------
defineExpose({ saveBase });
</script>
<style lang="scss" scoped></style>
